package com.tms.basic.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tms.basic.pojo.domain.Role;
import com.tms.basic.service.RoleService;
import com.tms.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
public class RoleController {
    
    @Autowired
    private RoleService roleService;
    
    @PostMapping("/listRole")
    public R<Page<Role>> listRole(Page<Role> page, Role role) {
        return R.success(roleService.listRoles(page, role));
    }
    
    @PostMapping("/addRole")
    public R<Boolean> addRole(@RequestBody Role role) {
        return R.success(roleService.createRole(role));
    }
    
    @PostMapping("/updateRole")
    public R<Boolean> updateRole(@RequestBody Role role) {
        return R.success(roleService.updateRole(role));
    }
    
    @PostMapping("/deleteRole/{id}")
    public R<Boolean> deleteRole(@PathVariable Long id) {
        return R.success(roleService.deleteRole(id));
    }
}